package com.zhou.common.mybatis.template.shiro.alibaba.sentinel.controller;

import com.zhou.common.mybatis.template.shiro.alibaba.sentinel.feign.TestFegin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class TestController {

    private final RestTemplate restTemplate;

    @Autowired
    public TestController(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    @RequestMapping(value = "/echo/{str}", method = RequestMethod.GET)
    public String echo(@PathVariable String str) {
        return restTemplate.getForObject("http://cloud-server/test/retry/" + str, String.class);
    }

    @Autowired
    private TestFegin testFegin;

    @RequestMapping(value = "/echo1/{str}", method = RequestMethod.GET)
    public String echo1(@PathVariable String str) {
        return testFegin.echo(str);
    }

    @RequestMapping(value = "/temeout", method = RequestMethod.GET)
    public String temeout() {
        return testFegin.testtTimout();
    }

    @RequestMapping(value = "/testException", method = RequestMethod.GET)
    public String testException() {
        return testFegin.testException();
    }
}

